package com.toutiao.action;

import java.util.List;
import com.base.dialect.PaginationSupport;
import com.base.dao.model.Ret;
import com.base.dao.model.Grid;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.apache.commons.lang.StringUtils;
import com.base.util.JSONUtils;
import com.base.web.annotation.LoginFilter;
import org.springframework.beans.factory.annotation.Autowired;
import com.base.action.CoreController;

import com.toutiao.dao.model.NewsCollect;
import com.toutiao.dao.model.NewsCollectExample;
import com.toutiao.service.NewsCollectService;

@RequestMapping("newsCollect")
@Controller
@LoginFilter
public class NewsCollectController extends CoreController{

	@Autowired
	private NewsCollectService newsCollectService;

	@RequestMapping("/list")
	@ResponseBody
	public String list(Integer page, Integer rows){
		PaginationSupport.byPage(page, rows);
		NewsCollectExample example = new NewsCollectExample();
		List<NewsCollect> list = newsCollectService.selectByExample(example);
		return JSONUtils.serialize(new Grid(PaginationSupport.getContext().getTotalCount(), list));
	}

	@RequestMapping("/findById")
	@ResponseBody
	public String find(Integer id){
		NewsCollect newsCollect = newsCollectService.selectByPrimaryKey(id);
		return JSONUtils.serialize(newsCollect);
	}

}